<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use app\modules\Product\models\Product;
use kartik\depdrop\DepDrop;
/* @var $this yii\web\View */
/* @var $model app\modules\Finance\models\InvoiceSearch */
/* @var $form yii\widgets\ActiveForm */

$product = [];
$cruise = [];
$time = date("Y-m-d",strtotime("-3 month"));
$arr = Product::find()->where(['>=','go_time', $time])->andWhere(['status'=>1])->groupBy('cruise_id')->all();
if($arr){
    foreach($arr as $v){
        $cruise[$v->cruise_id] = $v->cruise->name;
    }
}

 
$sort = [0=>'时间由近到远',1=>'时间由远到近'];

?>

<style type="text/css">
    .form-group{margin-bottom: 10px !important;}
</style>

<div class="invoice-search" style="padding:0 0 15px 0;">

    <?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'layout' => 'inline',
    ]); ?>


    <?= $form->field($model, 'code')->textInput(['placeholder'=>'发票单号' ]) ?>

    <?= $form->field($model, 'cruise_id')->dropDownList($cruise, ['id'=>'cruise_id','prompt' => '选择邮轮']) ?>
 
    <?= $form->field($model, 'product_id')->widget(DepDrop::classname(), [
        'options'=>['id'=>'product_id'],
        //'type' => DepDrop::TYPE_SELECT2,
        'pluginOptions'=>[
            'depends'=>['cruise_id'],
            'placeholder'=>'选择船期',
            'initialize' => true,
            'url'=>Url::to(['/finance/invoice/get-product'])
        ]
    ])?>
 

    <?= $form->field($model, 'order_code')->textInput(['placeholder'=>'订单编号' ]) ?>

    <?php echo $form->field($model, 'status')->dropdownList(Yii::$app->params['invoice_status'], ['prompt'=>Yii::t('app', 'Status')]) ?>

    <?php echo $form->field($model, 'company')->textInput(['placeholder'=>'付款单位', 'style'=>'width:130px;']) ?>

    <?php echo $form->field($model, 'min_price')->textInput(['placeholder'=>'最小金额', 'style'=>'width:130px;']) ?>

    <?php echo $form->field($model, 'max_price')->textInput(['placeholder'=>'最大金额', 'style'=>'width:130px;']) ?>

     <?php echo $form->field($model, 'sort')->dropdownList($sort) ?>

    <div class="form-group">
        <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
        <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
